//
//  SignExpertAgreementViewController.m
//  StraightTrain
//
//  Created by mk on 15/12/7.
//  Copyright © 2015年 mk. All rights reserved.
//

#import "SignExpertAgreementViewController.h"
#import "SignExpertSueecssViewController.h"

@interface SignExpertAgreementViewController ()

@end

@implementation SignExpertAgreementViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    titleLabel.text = @"专家签约协议";
    
//    [web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]]];
    
    NSString *filePath = [[NSBundle mainBundle]pathForResource:@"agreement" ofType:@"html"];
    NSURL *url = [NSURL fileURLWithPath:filePath];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [web loadRequest:request];
    
    btnCancle.layer.cornerRadius = 4;
    btnCancle.layer.borderWidth=1.0f;
    btnCancle.layer.borderColor=[UIColor redColor].CGColor;
    btnOK.layer.cornerRadius = 4;
}


-(void)webViewDidStartLoad:(UIWebView *)webView
{
    [indicat startAnimating];
    indicat.hidden = NO;
}

//完成
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    [indicat stopAnimating];
    indicat.hidden = YES;
}

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    [indicat stopAnimating];
    indicat.hidden = YES;
}

-(IBAction)btnOkClick:(id)sender
{
    [self updateAgreementMessage];
}

-(void)updateAgreementMessage
{
    SetHUDStartText(@"提交信息中..")
    NSMutableDictionary * dic = [[NSMutableDictionary alloc]initWithCapacity:0];
    [dic setObject:[gProjConfig.dicUserData objectForKey:USER_tel] forKey:@"applycontract[username]"];
    [dic setObject:[gProjConfig.dicUserData objectForKey:USER_token] forKey:@"applycontract[token]"];
    [dic setObject:self.strMess forKey:@"applycontract[preferred_patient]"];
    
    [[HttpClient manager]POST:NullObjToString([gProjConfig.dicAllUrl objectForKey:@"applycontractUrl"])
                   parameters:dic
                      success:^(AFHTTPRequestOperation *operation, id responseObject)
     {
         SetHUDHidden;
         SetHUDFinishedText(@"信息已提交")
         
     } failure:^(AFHTTPRequestOperation *operation, NSError *error)
     {
         SetHUDHidden;
         HUDShowRequestError(error.domain, self.view)
     }];
    
}

-(void)hudWasHidden:(MBProgressHUD *)hud
{
    SignExpertSueecssViewController * main = [[SignExpertSueecssViewController alloc]initWithNibName:@"SignExpertSueecssViewController" bundle:nil];
    [self.navigationController pushViewController:main animated:YES];
}




-(IBAction)btnCanale:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
